<p>
在本版交流，请遵守本版的版规，并服从管理员及版主的日常管理，共同维护一个良好的社区环境。
</p>
<?php
if($this->identity){
?>
<div class="forumButton">
<span><a href="/community/create-topic/fid/<?php echo $this->fid;?>"><img src = "/skins/common/new_topic.png" /></a></span>
</div>
<?php
}
?>

<table class="forum">
    <tr class="title">
        <th width="45%">主题</th>
        <th width="8%">作者</th>
        <th width="7%">时间</th>
        <th width="5%">回复</th>
        <th width="5%">查看</th>
        <th width="30%">最后回复</th>
    </tr>
<?php
    $modelPost = new Ms_Model_ForumPost();
    
    foreach ($this->topics as $topic){
        echo "<tr>";
        echo "<td><a href='/community/topic/id/".$topic->id."'>".$topic->subject."</a></td>";
        echo "<td>".$topic->username."</td>";
        echo "<td>".date("Y-m-d",$topic->time)."</td>";
        echo "<td>";
        $postNum = $modelPost->countPosts($topic->id);
        echo $postNum;
        echo "</td>";
        echo "<td>".$topic->views."</td>";
        echo "<td>";
        $lastPost = $modelPost->getLastPost($topic->id);
        if ($lastPost != null){
            if(mb_strlen($lastPost->post, 'utf-8') > 18){
                echo mb_substr(str_replace(array('<p>','</p>'), '', $lastPost->post), 0, 18,'utf-8').'...';
            }
            else{
                echo str_replace(array('<p>','</p>'), '', $lastPost->post);
            }
            echo "<span><a href='/user/account/id/".$topic->user_id."'>".$topic->username."</a></span>";
        }
        else{
            echo "无";
        }

        echo "</td>";
    echo "</tr>";
    }
?>

</table>

<?php 
if(count($this->topics) > 1 ){
    echo $this->paginationControl($this->topics,'Sliding','partials/pagination-control.phtml');
} 
?>
